

package cn.shengchao.examstar.comment.ohs.local.message;

import cn.shengchao.base.enums.DisEnableStatusEnum;
import cn.shengchao.examstar.comment.domain.entity.ProductComment;
import cn.shengchao.examstar.comment.domain.valobj.Content;
import cn.shengchao.examstar.comment.domain.valobj.Student;
import cn.shengchao.examstar.shared.application.ai.dto.CommentsFilterAndRateResult;
import lombok.Data;

@Data
public class CommentDto {
    private Long productId;
    // 评论内容
    private String content;
    // 评论分数
    private Double score;
    // 是否匿名
    private Boolean anonymity;

    public ProductComment toProductComment(Student student, CommentsFilterAndRateResult commentsFilterAndRateResult) {
        return ProductComment.builder()
            .productId(productId)
            .student(student)
            .content(new Content(content))
            .score(score)
            .anonymity(anonymity)
            .status("好评".equals(commentsFilterAndRateResult.getReviewType())
                ? DisEnableStatusEnum.ENABLE
                : DisEnableStatusEnum.APPROVAL)
            .filteredComment(commentsFilterAndRateResult.getFilteredComment())
            .sensitiveWordsFound(commentsFilterAndRateResult.getSensitiveWordsFound())
            .reviewType(commentsFilterAndRateResult.getReviewType())
            .reason(commentsFilterAndRateResult.getReason())
            .reply(commentsFilterAndRateResult.getReply())
            .build();
    }
}
